package tech.aistar.corejava.day12;

import java.util.Comparator;
import java.util.TreeMap;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:
 * @date 2019/7/30 0030
 */
public class TreeMapDemo {
    public static void main(String[] args) {
//        TreeMap<Integer,String> map = new TreeMap<>(new Comparator<Integer>() {
//            //针对key降序和升序
//            @Override
//            public int compare(Integer o1, Integer o2) {
//                return o2 - o1;
//            }
//        });

        //JDK8.0 lambda表达式
        TreeMap<Integer,String> map = new TreeMap<>((a,b) -> b - a);

        map.put(1,"a");
        map.put(2,"a");
        map.put(3,"a");
        //不允许
        //map.put(null,"null");

        System.out.println(map);
    }
}
